package com.henan.provideservice.api.response;

import lombok.Getter;
import lombok.Setter;

import java.time.LocalDateTime;

@Getter
@Setter
public class CommonResponse<T> {

    private Integer code = 0;

    private String message = "OK";

    private LocalDateTime dateTime = LocalDateTime.now();

    private T data;

    public static <T> CommonResponse<T> ofSuccess() {
        return new CommonResponse<>();
    }

    public static <T> CommonResponse<T> ofSuccess(T data) {
        CommonResponse<T> response = new CommonResponse<>();
        response.setData(data);
        return response;
    }

    public static <T> CommonResponse<T> ofError(Integer code, String message) {
        CommonResponse<T> response = new CommonResponse<>();
        response.setCode(code);
        response.setMessage(message);
        return response;
    }


}
